package com.compass.doctor.ui.mine.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutEvaluateItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.glide.setUrlCircle
import com.compass.framework.model.Evaluate
import com.compass.framework.model.ScreenTag
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 评价adapter
 * Date:2023/12/30 19:58
 */
class EvaluateAdapter : BaseRecyclerViewAdapter<Evaluate, LayoutEvaluateItemBinding>() {

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutEvaluateItemBinding {
        return LayoutEvaluateItemBinding.inflate(layoutInflater, parent, false)
    }

    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutEvaluateItemBinding>,
        item: Evaluate?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvData.text=DateUtils.conversionTime(item.createTime,DateUtils.FORMAT_TWO)
            tvAge.text = item.patientAge
            tvName.text=item.patientName
            ivHead.setUrlCircle(item.patientAvatar)
            ivSex.background= if (item.sex==1) getDrawableResource(R.mipmap.icon_male) else  getDrawableResource(
                R.mipmap.icon_female)
            ratBar.starProgress=item.evaluationGrade
            tvContent.text=item.content
            tvServiceType.text="服务类型：${item.type}"
            if (position==getData().size-1) viewLine.visibility= View.GONE else viewLine.visibility= View.VISIBLE
        }
    }
}